package com.yunlongn.async.log;

import com.yunlongn.async.config.RetrySchedulerConfig;
import com.yunlongn.async.log.impl.MemoryScheduleServiceImpl;
import com.yunlongn.async.log.impl.RedisScheduleServiceImpl;
import com.yunlongn.async.util.spi.SpiLoader;

/**
 * @author yunlong.li
 */
public class LoggerManager {

    private static RetryScheduleLogService logger;

    static {
        logger = SpiLoader.loadFistNotDefaultService(Thread.currentThread().getContextClassLoader(),
                RetryScheduleLogService.class, RedisScheduleServiceImpl.class);
        if (RetrySchedulerConfig.getStringRedisTemplate() == null) {
            logger = SpiLoader.loadFistNotDefaultService(Thread.currentThread().getContextClassLoader(),
                    RetryScheduleLogService.class, MemoryScheduleServiceImpl.class);
        }
    }

    public static RetryScheduleLogService getLogger() {
        return logger;
    }
}
